package priv.blackbibo.application.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import priv.blackbibo.application.activity.MusicActivity;
import priv.blackbibo.application.service.MusicService;

/**
 * Created by black on 2019-12-16.
 */
public class PluginReceiver extends BroadcastReceiver {
    private static final String TAG = "PluginReceiver";

    public PluginReceiver() {
        Log.d(TAG, "PluginReceiver: init");
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.hasExtra("state")) {
            if (intent.getIntExtra("state", 0) == 0) {
                MusicService.interupt();
            } else if (intent.getIntExtra("state", 0) == 1) {
                Intent action = new Intent(context ,MusicService.class);
                action.putExtra("action", MusicService.ACTION_START);
                context.startService(action);
            }
        }
    }
}
